import App from 'koa'
import Router from 'koa-router'

const app = new App()
const router = new Router()

router.get('/', (ctx) => {
  // ctx.body = `<h1>欢迎访问服务器！</h1>`
  ctx.body = `
<!-- vue的引入 -->
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<div id="app">{{ message }}</div>
<script>
  const { createApp, ref } = Vue
  createApp({
    setup() {
      const message = ref('Hello vue!')
      return {
        message,
      }
    },
  }).mount('#app')
</script>
  `
})
app.use(router.routes()).use(router.allowedMethods())
app.listen(3000, () => {
  console.log('服务器开启成功，请访问http://localhost:3000')
})
